//
//  CGFloat+Extensions.swift
//  HomeShop
//
//  Created by 刘泽 on 2018/2/11.
//  Copyright © 2018年 刘泽. All rights reserved.
//

import Foundation
import UIKit

extension CGFloat{
    
    public func toString() -> String {
        return String(describing: self)
    }
    
    public func toInt() -> Int {
        return Int(self)
    }
    public func toFloat() -> Float {
        return Float(self)
    }
    public func toDouble() -> Double {
        return Double(self)
    }

    public func format(_ count : Int) -> String{
        return String(format: "%.\(count)f", self)
    }

    public func decimals(_ count : Int) -> CGFloat{
        return CGFloat(Double(String(format: "%.\(count)f", self)) ?? 0)
    }
    
}
